<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
	$helper = Mage::helper('wishcartsettings');
    $pageLayout = substr((str_replace(array('page/','.phtml'),'',Mage::app()->getLayout()->getBlock('root')->getTemplate())),0,1);
	if ($pageLayout == 1) $_columnCount = 4;
	if ($pageLayout == 2) $_columnCount = 3;
	if ($pageLayout == 3) $_columnCount = 2;
	$isMobile = $helper->checkMobilePhp();
    if($isMobile == 'true')	$_columnCount=1;
?>
<?php if(count($this->getItemCollection()->getItems())): ?>
<?php $count = count($this->getItemCollection()->getItems()); ?>
<div class="box-collateral box-up-sell">
    <h2><strong><span><?php echo $this->__('You may also be interested in the following product(s)') ?></span></strong></h2>
    <div id="upsell-product-table">
		<ul class="products-grid slides">
			<?php $this->resetItemsIterator() ?>
			<?php $i=0;foreach($this->getItemCollection()->getItems() as $_link): ?>
				<li class="item <?php if($_link->getData('gala_label_style') == '')echo 'corner';else echo $_link->getData('gala_label_style'); ?><?php if($i == 0):?> first<?php elseif($i == $count-1):?> last<?php endif ?>">
					<a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_link->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(200) ?>" width="200" height="200" alt="<?php echo $this->escapeHtml($_link->getName()) ?>" />
					<?php echo $helper->getLabelProducts($_link->getId()) ?>
					</a>
					
					<div class="product-shop product-shop-color">
						<div class="f-fix">
							<div class="f-fix-content">
								<?php echo $helper->getBrandProducts($_link->getId()) ?>

								<h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_link->getName()) ?>"><?php echo $this->escapeHtml($_link->getName()) ?></a></h3>

								<?php echo $this->getReviewsSummaryHtml($_link,"short") ?>

								<?php if($_link->isSaleable()): ?>
									<p class="availability in-of-stock"><span><?php echo $this->__('In of stock') ?></span></p>
								<?php endif; ?>

								<?php 
									$desc	=	Mage::helper('catalog/output')->productAttribute($_link, $_link->getShortDescription(), 'short_description');
									$limit_text	=	100;	// number of characters
									if(strlen($desc) > $limit_text) {
										$desc 	= substr($desc,0,$limit_text);
										$plit	=	explode(" ",$desc);unset($plit[count($plit)]);
										$desc	=	implode(" ",$plit).' ...';
									}
								?>
								<div class="desc std">
									<?php echo $desc ?>
									<a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $_link->getName() ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
								</div>

								<?php echo $this->getPriceHtml($_link, true, '-upsell') ?>

								<div class="actions">
									<ul class="add-to-links">
										<?php if($_compareUrl=$this->getAddToCompareUrl($_link)): ?>
											<li><a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
										<?php endif; ?>
										<?php if ($this->helper('wishlist')->isAllow()) : ?>
											<li><span class="separator">|</span> <a href="<?php echo $this->helper('wishlist')->getAddUrl($_link) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
										<?php endif; ?>
									</ul>
									<?php if($_link->isSaleable()): ?>
										<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_link) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
									<?php endif; ?>
								</div>

							</div>
						</div>
					</div>
				</li>
			<?php $i++;endforeach ?>
		</ul>
		<?php //if($count > $_columnCount): ?>
			<script type="text/javascript">
				jQuery(window).load(function() {
					jQuery('#upsell-product-table').csslider({
						move : 1,
						direction : 'horizontal'
					});
				});
			</script>
		<?php //endif ?>
    </div>
    <script type="text/javascript">decorateTable('upsell-product-table')</script>
</div>
<?php endif ?>
